package com.lichuang.fruitvarietysm.goods.controller;


import com.lichuang.fruitvarietysm.goods.entity.Category;
import com.lichuang.fruitvarietysm.goods.service.impl.CategoryServiceImpl;
import io.swagger.annotations.Api;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cache.annotation.Cacheable;
import org.springframework.web.bind.annotation.RequestMapping;

import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * <p>
 * 分类表 前端控制器
 * </p>
 *
 * @author shuaihang
 * @since 2019-05-15
 */
@RestController
@RequestMapping("//category")
@Api(value = "category")
public class CategoryController {

    @Autowired
    private CategoryServiceImpl categoryService;

    @RequestMapping("/getCategory")
    @Cacheable(value = "getCategory")
    public List<Category> getCategory(@RequestParam("parent_id")Integer parent_id){
        List<Category> list=categoryService.getCategory(parent_id);
        return list;
    }

    @RequestMapping("/getCategoryName")
    public List<Category> getCategoryName(@RequestParam("parent_id")Integer parent_id){
      List<Category>  categoryList= categoryService.getCategoryName(parent_id);
        System.out.println(categoryList);
        return  categoryList;
    }


}
